package org.dx.oho.enums;

import org.jetbrains.annotations.Nullable;

/**
 * 店铺操作异常枚举类 create by duanx 2021/1/31
 *@classname: ShopException
 *@author: duanx
 *@date: 2021/1/31 20:19
 **/
public enum ShopStateEnum {
    /**
     * 审核中
     */
    CHECK(0,"审核中"),
    /**
     * 非法店铺
     */
    OFFLINE(-1,"非法店铺"),
    /**
     * 操作成功
     */
    SUCCESS(1,"操作成功"),
    /**
     * 通过认证
     */
    PASS(2,"通过认证"),
    /**
     * 系统内部错误
     */
    INNER_ERROR(-1001,"系统内部错误"),
    /**
     * ShopId为空
     */
    NULL_SHOP_ID(-1002,"ShopId为空"),
    /**
     * 空值
     */
    NULL_SHOP(-1003,"空值")
    ;

    private int state;
    private String stateInfo;

    /**
     * 私有化是因为不能修改
    */
    ShopStateEnum(int state, String stateInfo){
         this.state = state;
         this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }
    public String getStateInfo() {
        return stateInfo;
    }


    /**
     * 根据传入的参数获取 stateEnum;
     * @param state 状态码
     * @return stateEnum
     */
    @Nullable
    public static ShopStateEnum stateEnum(int state){
         for (ShopStateEnum stateEnum : values()){
             if (stateEnum.getState() == state){
                 return stateEnum;
             }
         }
         return null;
    }
}
